package com.sysofstudent.web.stu;


import com.sysofstudent.dao.ScoreRepository;
import com.sysofstudent.po.Score;
import com.sysofstudent.po.Student;
import com.sysofstudent.service.ScoreService;
import com.sysofstudent.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;


@Controller
public class StudentController {

    @Resource
    StudentService studentService;

    @RequestMapping("/student/personal{number}")
    public String personal(Model model,@PathVariable String number)
    {
        Student student=studentService.findStudent(number);
        model.addAttribute("student",student);
        return"/student/personal";
    }

    @RequestMapping("/student/InfoToEdit{number}")
    public String InfoToEdit(Model model,@PathVariable String number)
    {
        Student student = studentService.findStudent(number);
        model.addAttribute("student",student);
        return "/student/InfoToEdit";
    }

    @RequestMapping("/student/InfoEdit")
    public String InfoEdit(Student student)
    {
        studentService.edit(student);
        return "redirect:/student";
    }

    @RequestMapping("/student/toEditPassword{number}")
    public String toEditPassword(Model model,@PathVariable String number)
    {
        Student student =studentService.findStudent(number);
        model.addAttribute("student",student);
        return "/student/toEditPassword";
    }

    @RequestMapping("/student/EditPassword")
    public String EditPassword(Student student)
    {
        studentService.edit(student);
        return "redirect:/student";
    }




}
